﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Unity;
using Microsoft.Practices.Composite.Regions;
using MP3Ganizer.Modules.FileView.ViewModels;
using MP3Ganizer.Common;

namespace MP3Ganizer.Modules.FileView.Controllers
{
  /// <summary>
  /// Controller du FileView
  /// </summary>
  public class FileViewMainController: IFileViewMainController
  {
    #region Fields
    private readonly IUnityContainer _container;
    private readonly IRegionManager _regionManager;
    private readonly IFileViewListVM _fileViewMainVM;
    #endregion

    #region Constructor
    /// <summary>
    /// Constructeur. Les paramètres sont pré-remplis par le UnityContainer.
    /// </summary>
    /// <param name="container"></param>
    /// <param name="regionManager"></param>
    /// <param name="FileViewMainVM"></param>
    public FileViewMainController(IUnityContainer container, IRegionManager regionManager, IFileViewListVM fileViewMainVM)
    {
      this._container = container;
      this._regionManager = regionManager;
      this._fileViewMainVM = fileViewMainVM;
    }
    #endregion

    #region IFileViewMainController Members

    /// <summary>
    /// Lance le Controller: Injecte la vue dans la région
    /// </summary>
    public void Run()
    {
      this._regionManager.RegisterViewWithRegion(RegionNames.FileViewList,
                                        () => this._fileViewMainVM.MainView);
    }
    #endregion
  }
}
